﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ControllerLag;
using Model;

namespace Projekt_1
{
    public partial class FrmFindHomeparty : Form
    {
        Controller controller;
        public FrmFindHomeparty(Controller controller)
        {
            InitializeComponent();
            this.controller = controller;
        }

        private void btnFindHomeparty_Click(object sender, EventArgs e)
        {
            foreach (Homeparty hp in controller.HentHomepartyListe())
            {
                ListViewItem i = new ListViewItem();
                i.Text = hp.Id.ToString();
                i.SubItems.Add(hp.Værtinde.Navn);
                i.SubItems.Add(hp.Dato.ToString());
                i.SubItems.Add(hp.Region.ToString());
                i.SubItems.Add(hp.Sælger.ToString());
                lstHomeparty.Items.Add(i);
            }
        }

        private void btnHentGæsteliste_Click(object sender, EventArgs e)
        {
            int selectedIndex;

            if (int.TryParse(lstHomeparty.SelectedItems[0].Text, out selectedIndex))
            {
                foreach (Homeparty hp in controller.HentHomepartyListe()) 
                {
                    for (int i = 0; i < hp.Gæsteliste.Count; i++)
                    {
                        ListViewItem lst = new ListViewItem();
                        lst.Text = hp.Gæsteliste[i].KundeNr.ToString();
                        lst.SubItems.Add(hp.Gæsteliste[i].Navn);
                        lst.SubItems.Add(hp.Gæsteliste[i].Adresse);
                        lst.SubItems.Add(hp.Gæsteliste[i].PostNr.ToString());
                        lst.SubItems.Add(hp.Gæsteliste[i].TlfNr.ToString());
                        lst.SubItems.Add(hp.Gæsteliste[i].Mail);
                        lstGæsteliste.Items.Add(lst);
                    }                    
                }
            }
            else
            {
                MessageBox.Show("Vælg et homeparty");
            }
        }

        private void btnLuk_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnFindHomeparty_Click_1(object sender, EventArgs e)
        {
            
        }

        private void btnHentGæsteliste_Click_1(object sender, EventArgs e)
        {
            
        }

        private void btnLuk_Click_1(object sender, EventArgs e)
        {
            this.Close();
        }

       
       
    }
}
